/*在界面上有4个按钮和文本框，分别为1,2,3,close，当点击1时，在文本框上显示1；同理，当点击2时，在文本框上显示2，当点击close时，关闭界面*/
#include "mainWindow.h"
#include <QDebug>

mainWindow::mainWindow(QWidget * parent,Qt::WindowFlags f)
:QWidget(parent,f)
{
    this->layout=new QVBoxLayout(this);
    this->layout2=new QHBoxLayout(this);

    this->textEdit=new QTextEdit(this);
    
    this->pushButton1=new QPushButton(this);
    this->pushButton1->setText("1");
    this->pushButton2=new QPushButton(this);
    this->pushButton2->setText("2");
    this->pushButton3=new QPushButton(this);
    this->pushButton3->setText("3");
    this->pushButton4=new QPushButton(this);
    this->pushButton4->setText("4");

    this->layout->addWidget(textEdit);
    this->layout2->addWidget(pushButton1);
    this->layout2->addWidget(pushButton2);
    this->layout2->addWidget(pushButton3);
    this->layout2->addWidget(pushButton4);
    this->layout->addLayout(layout2);

    this->setLayout(layout);

    connect(this->pushButton1,SIGNAL(clicked()),this,SLOT(myClicked1()));
    connect(this->pushButton2,SIGNAL(clicked()),this,SLOT(myClicked2()));
    connect(this->pushButton3,SIGNAL(clicked()),this,SLOT(myClicked3()));
    connect(this->pushButton4,SIGNAL(clicked()),this,SLOT(myClicked4()));

}

void mainWindow::myClicked1()
{
    this->textEdit->clear();
    this->textEdit->append("1");
}
void mainWindow::myClicked2()
{
    this->textEdit->clear();
    this->textEdit->append("2");
}
void mainWindow::myClicked3()
{
    this->textEdit->clear();
    this->textEdit->append("3");
}
void mainWindow::myClicked4()
{
    this->close();
}